import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import { Rank } from '../entity/Rank';
import { Utils } from '../common/Utils';
import { Ally } from '../entity/Ally';
const { ccclass, property } = _decorator;

@ccclass('UnionItem')
export class UnionItem extends Component {
    @property(Label)
    index:Label
    @property(Label)
    unionName:Label
    @property(Label)
    count:Label
    @property(Label)
    people:Label
    @property(Label)
    point:Label
    @property(SpriteFrame)
    activeBg:SpriteFrame

    start() {

    }

    setData(rank:Rank) {
        this.index.string = rank.AllyRank + ''
        this.unionName.string = rank.AllyName
        this.count.string = rank.PlayerNum + ''
        this.people.string = rank.AvgPeople + ''
        this.point.string = rank.AllyPoint + ''

        Utils.handleEllipsis(this.unionName.node)
        
        if(rank.AllyId == Ally.getMyAlly().AllyId){
            this.getComponent(Sprite).spriteFrame = this.activeBg
        }
    }
}


